package com.ruoyi.wx.service.serviceImpl;

import com.ruoyi.wx.domain.AttendanceRecord;
import com.ruoyi.wx.domain.vo.AttendanceRecordVo1;
import com.ruoyi.wx.mapper.AttendanceRecordMapper;
import com.ruoyi.wx.service.IAttendanceRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service("wxAttendanceRecordService")
public class AttendanceRecordServiceImpl implements IAttendanceRecordService {
    @Autowired
    @Qualifier("wxAttendanceRecordMapper")
    private AttendanceRecordMapper attendanceMapper;

    @Override
    public int selectAttendanceByRecordData(AttendanceRecord attendance) {
        AttendanceRecord attendanceRecord = attendanceMapper.selectAttendanceByRecordData(attendance);
        if (attendanceRecord != null) {
            return 1;
        }
        return 0;
    }

    @Override
    public int insertAttendanceRecord(AttendanceRecordVo1 attendanceRecord) {
        System.out.println(attendanceRecord);

        if (attendanceRecord.getTitle().equals("转正申请")) {
            attendanceRecord.setCurrentApproverId((long)101);
            attendanceRecord.setCategoryId((long)2);
            return attendanceMapper.insertAttendanceRecord1(attendanceRecord);
        } else if (attendanceRecord.getTitle().equals("请假申请")) {
            attendanceRecord.setCurrentApproverId((long)1);
            attendanceRecord.setCategoryId((long)5);
            return attendanceMapper.insertAttendanceRecord1(attendanceRecord);
        }
        attendanceRecord.setCurrentApproverId((long)1);
        attendanceRecord.setCategoryId((long)4);
        return attendanceMapper.insertAttendanceRecord1(attendanceRecord);
    }
}
